package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.ProjectStatus;
import com.cloudfun.campusshare.common.constant.ProjectType;
import lombok.*;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * @author : ashsr.zhang
 * @date : 2020/3/3 15:31
 * @Version : v1.0
 * @description 项目
 **/
@Data
@Entity
@Builder
@ToString(exclude = {"loan"})
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "project")
public class ProjectEntity extends BaseEntity {
    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", nullable = false, unique = true, length = 40)
    private String id;

    @Column(name = "user_id", columnDefinition = ("varchar(40) not null comment '用户Id'"))
    private String userId;

    @Column(name = "name", columnDefinition = ("varchar(255) default null comment '项目名称'"))
    private String name;

    @Column(name = "type", columnDefinition = ("varchar(32) default null comment '项目类型 0 洗衣机 1 热水系统'"))
    @Enumerated(EnumType.STRING)
    private ProjectType type;

    @Column(name = "belong_school", columnDefinition = ("varchar(255) default null comment '所属学校'"))
    private String belongSchool;

    @Column(name = "device_count", columnDefinition = ("int(11) default null comment '接入设备数量'"))
    private Integer deviceCount;

    @Column(name = "winning_bid_time", columnDefinition = ("varchar(14) default null comment '中标时间'"))
    private String winningBidTime;

    @Column(name = "operation_start_time", columnDefinition = ("varchar(14) default null comment '开始运营时间'"))
    private String operationStartTime;

    @Column(name = "project_due_time", columnDefinition = ("varchar(14) default null comment '项目到期时间'"))
    private String projectDueTime;

    @Column(name = "status", columnDefinition = ("varchar(32) default null comment '项目状态 0 准备中 1运营中'"))
    @Enumerated(EnumType.STRING)
    private ProjectStatus status;

    @Column(name = "project_summary", columnDefinition = ("varchar(1024) default null comment '项目概述'"))
    private String projectSummary;

    @Column(name = "loan_id", columnDefinition = ("varchar(40) default null comment '融资贷款id'"))
    private String loanId;

    @ManyToOne
    @JoinColumn(name = "loan_id", updatable = false, insertable = false)
    private LoanEntity loan;

    @Column(name = "school_id", columnDefinition = ("varchar(40) default null comment '学校id'"))
    private String schoolId;
}
